package org.dydl.dao.system.repository;

import org.dydl.model.system.Goods;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;


@Repository
public interface IMaterialRepertoryRepository extends CrudRepository<Goods, Integer>,JpaSpecificationExecutor<Goods>{
//	//WHERE go.type = YL    @Param("type") String type,
//	@Query(value = " FROM Goods go  ", countQuery = "SELECT count(go.id) FROM Goods go ")
//	public Page<Goods> getGoodsList(Pageable pageable);
	
	@Query(value = " FROM Goods go  WHERE go.type = 'YL' ", countQuery = "SELECT count(go.id) FROM Goods go")
	public Page<Goods> getMaterialRepertoryList(Pageable pageable);
	

	@Query(value = " FROM Goods go WHERE go.name LIKE :name  AND  go.type = 'YL'",
			countQuery = "SELECT count(go.id) FROM Goods go WHERE go.name LIKE :name AND  go.type = 'YL'")
	public Page<Goods> getMaterialRepertoryListLike(@Param("name") String name, Pageable pageable);
	
}
